package com.opal.system.entity.table;

import com.opal.consts.CommonConst;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;
import java.util.Date;

@Slf4j
public class OpalUser implements HttpSessionBindingListener {
    private Long userId;

    private String userCode;

    private String userName;

    private String userMail;

    private String userPassword;

    private String userRoles;

    private String userSalt;

    private String hrorgPkhrorg;

    private String userDept;

    private Integer userPosition;

    private Date userCreated;

    private Date userUpdated;

    private String pkOrg;

    public void valueBound(HttpSessionBindingEvent event) {
        OpalUser user = (OpalUser) event.getValue();
        log.info(user.userName+":用户登录！");
    }


    public void valueUnbound(HttpSessionBindingEvent event) {
        log.info("用户会话已结束，清除数据开始。。。");
        //获取退出会话的用户
        OpalUser user = (OpalUser) event.getValue();
        Long userId=null;
        if (user==null){
            userId=-1l;
        }
        //收发存汇总表中的用户数据
        CommonConst.hr.remove(userId);
        //签卡单
        CommonConst.currentbillCode.remove(userId);
        CommonConst.currentPkOrg.remove(userId);
        CommonConst.currentPkSignh.remove(userId);
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getUserCode() {
        return userCode;
    }

    public void setUserCode(String userCode) {
        this.userCode = userCode == null ? null : userCode.trim();
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName == null ? null : userName.trim();
    }

    public String getUserMail() {
        return userMail;
    }

    public void setUserMail(String userMail) {
        this.userMail = userMail == null ? null : userMail.trim();
    }

    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword == null ? null : userPassword.trim();
    }

    public String getUserRoles() {
        return userRoles;
    }

    public void setUserRoles(String userRoles) {
        this.userRoles = userRoles == null ? null : userRoles.trim();
    }

    public String getUserSalt() {
        return userSalt;
    }

    public void setUserSalt(String userSalt) {
        this.userSalt = userSalt == null ? null : userSalt.trim();
    }

    public String getHrorgPkhrorg() {
        return hrorgPkhrorg;
    }

    public void setHrorgPkhrorg(String hrorgPkhrorg) {
        this.hrorgPkhrorg = hrorgPkhrorg == null ? null : hrorgPkhrorg.trim();
    }

    public String getUserDept() {
        return userDept;
    }

    public void setUserDept(String userDept) {
        this.userDept = userDept == null ? null : userDept.trim();
    }

    public Integer getUserPosition() {
        return userPosition;
    }

    public void setUserPosition(Integer userPosition) {
        this.userPosition = userPosition;
    }

    public Date getUserCreated() {
        return userCreated;
    }

    public void setUserCreated(Date userCreated) {
        this.userCreated = userCreated;
    }

    public Date getUserUpdated() {
        return userUpdated;
    }

    public void setUserUpdated(Date userUpdated) {
        this.userUpdated = userUpdated;
    }

    public String getPkOrg() {
        return pkOrg;
    }

    public void setPkOrg(String pkOrg) {
        this.pkOrg = pkOrg;
    }
}